{include file="public/head" /}
  
  <body>
    <div class="x-body">
        <form class="layui-form" method="post" action="{:url('add')}">

            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>类型</label>
                <div class="layui-input-block">
                    <input checked type="radio" lay-skin="primary" value="1" title="小区门" lay-filter="1" name="deviceType">
                    <input type="radio" lay-skin="primary" value="2" title="单元门" lay-filter="2" name="deviceType">
                    <input type="radio" lay-skin="primary" value="3" title="电梯" lay-filter="3" name="deviceType">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="community_id" class="layui-form-label">
                    <span class="x-red">*</span>所属小区:
                </label>
                <div class="layui-input-inline" style="width: 300px;">
                    <select name="community_id" id="community_id">
                        <option value=""><------选择小区------></option>
                        {foreach $communitylist as $community}
                        <option value="{$community.id}">{$community.community_name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="layui-form-item" id="boxGroup">
                <label  class="layui-form-label">
                    <span class="x-red">*</span>组团:
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="group" lay-verify="requiredIfChecked"
                           autocomplete="off" class="layui-input" style="width:300px;">
                </div>
            </div>
            <div class="layui-form-item" id="boxBuilding">
                <label  class="layui-form-label">
                    <span class="x-red">*</span>楼栋:
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="building" lay-verify="requiredIfChecked"
                           autocomplete="off" class="layui-input" style="width:300px;">
                </div>
            </div>
            <div class="layui-form-item" id="boxUnit">
                <label  class="layui-form-label">
                    <span class="x-red">*</span>单元:
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="unit" lay-verify="requiredIfChecked"
                           autocomplete="off" class="layui-input" style="width:300px;">
                </div>
            </div>

            <div class="layui-form-item">
                <label  class="layui-form-label">
                    <span class="x-red">*</span>添加位置:
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="lockname" required
                    autocomplete="off" class="layui-input" style="width:300px;">
                </div>
            </div>
            <div class="layui-form-item">
                <label  for="devicekey" class="layui-form-label">
                    <span class="x-red"></span>设备key:
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="devicekey" id="devicekey"
                           autocomplete="off" class="layui-input" style="width:300px;">
                </div>
            </div>
            <div class="layui-form-item">
                <label  for="imei" class="layui-form-label">
                    <span class="x-red">*</span>模组id:
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="imei" id="imei" required
                           autocomplete="off" class="layui-input" style="width:300px;">
                </div>
            </div>




          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">
                  添加
              </button>
          </div>
      </form>
    </div>

    <script>
        layui.use(['form'], function() {
            var form = layui.form;
            $('#boxGroup').hide();
            $('#boxBuilding').hide();
            $('#boxUnit').hide();
            $('#input').removeAttr('lay-verify');
            form.on('radio(1)',function(data){
                $('#boxGroup').hide();
                $('#boxBuilding').hide();
                $('#boxUnit').hide();
                $('#input').removeAttr('lay-verify');
            })
            form.on('radio(2)',function(data){
                $('#boxGroup').show();
                $('#boxBuilding').show();
                $('#boxUnit').show();
                $('#input').attr('lay-verify', 'required');
            })
            form.on('radio(3)',function(data){
                $('#boxGroup').show();
                $('#boxBuilding').show();
                $('#boxUnit').show();
                $('#input').attr('lay-verify', 'required');
            })



        })
    </script>
    <script>var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();</script>
  </body>

</html>